//package com.inspur.edp.cef.generator.repository.entity.methods;
//
//import com.inspur.edp.caf.generator.baseInfo.ParameterInfo;
//import com.inspur.edp.caf.generator.baseInfo.TypeInfo;
//import com.inspur.edp.caf.generator.method.ClassMethodGenerator;
//import com.inspur.edp.cef.designtime.api.entity.MdRefInfo;
//import com.inspur.edp.cef.spi.common.ComponentInvokUtil;
//import com.inspur.edp.das.commonmodel.IGspCommonObject;
//import org.eclipse.jdt.core.dom.*;
//
//import java.util.ArrayList;
//import java.util.Arrays;
//import java.util.List;
//
//public class GetAdapterExtendClassesMethodGenerator extends ClassMethodGenerator {
//    private IGspCommonObject dataType;
//    private static String varListName="list";
//
//    public GetAdapterExtendClassesMethodGenerator(IGspCommonObject dataType)
//    {
//
//        this.dataType = dataType;
//    }
//
//    @Override
//    protected Block buildMethodBody() {
//        Block block=ast.newBlock();
//        addInitListStatement(block);
//        addAddItemsStatements(block);
//        addReturnListStatement(block);
//        return block;
//    }
//
//    //List<String> list =new ArrayList();
//    private void addInitListStatement(Block block) {
//        VariableDeclarationFragment variableDeclarationFragment= getListVarDefFragment(block);
//        VariableDeclarationStatement variableDeclarationStatement=ast.newVariableDeclarationStatement(variableDeclarationFragment);
//        setListVarType(variableDeclarationStatement);
//        block.statements().add(variableDeclarationStatement);
//    }
//
//    private VariableDeclarationFragment getListVarDefFragment(Block block) {
//        VariableDeclarationFragment variableDeclarationFragment =ast.newVariableDeclarationFragment();
//        variableDeclarationFragment.setName(ast.newSimpleName(varListName));
//        setListVarInitializer(variableDeclarationFragment);
//        return variableDeclarationFragment;
//    }
//
//    private void setListVarInitializer(VariableDeclarationFragment variableDeclarationFragment) {
//        ClassInstanceCreation classInstanceCreation=ast.newClassInstanceCreation();
//        classInstanceCreation.setType(ast.newSimpleType(ast.newName(ArrayList.class.getTypeName())));
//        variableDeclarationFragment.setInitializer(classInstanceCreation);
//    }
//
//    private void setListVarType(VariableDeclarationStatement variableDeclarationStatement) {
//        ParameterizedType type=ast.newParameterizedType(ast.newSimpleType(ast.newSimpleName(List.class.getSimpleName())));
//        type.typeArguments().add(ast.newSimpleType(ast.newSimpleName(String.class.getSimpleName())));
//        variableDeclarationStatement.setType(type);
//    }
//
//    private void addAddItemsStatements(Block block) {
//        if(dataType.getRepositoryComps()==null||dataType.getRepositoryComps().size()==0)
//            return;
//        for(MdRefInfo info:dataType.getRepositoryComps())
//        {
//            String typeName=  ComponentInvokUtil.getInstance(info.getId()).getClass().getTypeName();
//            MethodInvocation methodInvocation=ast.newMethodInvocation();
//            methodInvocation.setName(ast.newSimpleName("add"));
//            methodInvocation.setExpression(ast.newSimpleName(varListName));
//            StringLiteral stringLiteral=ast.newStringLiteral();
//            stringLiteral.setEscapedValue(typeName);
//            methodInvocation.arguments().add(stringLiteral);
//
//            block.statements().add(methodInvocation);
//        }
//    }
//
//    private void addReturnListStatement(Block block) {
//        ReturnStatement returnStatement=ast.newReturnStatement();
//        returnStatement.setExpression(ast.newSimpleName(varListName));
//        block.statements().add(returnStatement);
//    }
//
//    @Override
//    protected String getMethodName() {
//        return "getAdapterExtendClasses";
//    }
//
//    @Override
//    protected TypeInfo getReturnType() {
//        TypeInfo typeInfo=new TypeInfo(List.class);
//        typeInfo.setIsParameterizedType(true);
//        typeInfo.getArguments().add(new TypeInfo(String.class));
//        return typeInfo;
//    }
//
//    @Override
//    protected ArrayList<Modifier.ModifierKeyword> getAccessModifiers() {
//        ArrayList<Modifier.ModifierKeyword> list =new ArrayList<Modifier.ModifierKeyword>();
//        list.add(Modifier.ModifierKeyword.PUBLIC_KEYWORD);
//        return list;
//    }
//
//    @Override
//    protected ArrayList<ParameterInfo> getParameterCollection() {
//        return null;
//    }
//
//    @Override
//    protected boolean getIsOverride() {
//        return true;
//    }
//}
